import request from '@/utils/request'
import {AddRequest, ListRequest, RemoveRequest, StockInBalanceRequest} from '@/interface/stockin'

export const StockInListR = (req: ListRequest) => {
  return request({
    method: 'GET',
    url: '/stockin',
    params: req,
  })
}

//添加入库单
export const StockInAddR = (req: AddRequest) => {
  console.log('添加入库单：', req)
  req.date /= 1
  return request({
    method: 'POST',
    url: '/stockin',
    data: JSON.stringify(req),
  })
}

//删除入库单
export const StockInRemoveR = (req:RemoveRequest) => {
  return request({
    method: 'DELETE',
    url: `/stockin`,
    params: req
  })
}


//修改入库单
export const StockInUpdateR = (req: AddRequest) => {
  console.log('修改入库单表单:', req)
  req.date /= 1
  return request({
    method: 'PUT',
    url: '/stockin',
    // data: data,
    data: JSON.stringify(req),
  })
}

//入库单汇总数据
export const StockInSummaryR = () => {
  return request({
    method: 'GET',
    url: '/stockin/summary'
  })
}

//patch:更新入库单
export const StockInBalanceR = (req:StockInBalanceRequest) => {
  return request({
    method: 'PATCH',
    url: '/stockin/balance',
    data: JSON.stringify(req)
  })
}